<template>
	<view class="login">
		<view class="login-head">
			<view class="head-box">
				<view class="logo">
					<view class="" style="position: absolute;left: 20rpx;top: 22rpx;z-index: 999;" @click="goback()">
						<svg t="1730859753212" class="icon" viewBox="0 0 1024 1024" version="1.1"
							xmlns="http://www.w3.org/2000/svg" p-id="4250" width="18" height="18">
							<path
								d="M474.496 512l338.752-338.752-90.496-90.496L293.504 512l429.248 429.248 90.496-90.496z"
								fill="#A6B2C0" p-id="4251"></path>
						</svg>
					</view>
					<!-- <image @click="goback()" class="close" src="../../static/img/close.png" mode=""></image> -->
					<view class="title">个人中心</view>
				</view>

			</view>
		</view>
		<view class="main">
			<view class="con">
			
			
				
				<view
					style="display: flex;align-items: center;padding: 30rpx 20rpx;margin-bottom: 20rpx;justify-content: space-between;border-bottom: 1rpx solid #303439;flex: 3;">
					<view class="" style="display: flex;align-items: center;" >
						<image src="../../static/img/avatar.webp" mode="" style="width: 100rpx;height: 100rpx;">
						</image>
						<!-- <view class="">
							<view style="margin-left: 20rpx;font-size: 24rpx;" class="color-b">{{item.name}}</view>
							<view style="margin-left: 20rpx;font-size: 22rpx;color: #9ba6b3;" class="">投注金额: {{item.money}}</view>
						</view> -->
					</view>
					<view class="color-b" style="font-size: 24rpx;">
						
					</view>
					<!-- <view class="">
						<svg t="1730859886122" class="icon" viewBox="0 0 1024 1024" version="1.1"
							xmlns="http://www.w3.org/2000/svg" p-id="4438" width="12" height="12">
							<path d="M324.3 960.1l-72.8-72.8L626.9 512 251.5 136.7l72.8-72.8L772.5 512z" fill="#A6B2C0"
								p-id="4439"></path>
						</svg>
					</view> -->
				</view>
				<view
					style="display: flex;align-items: center;padding: 30rpx 20rpx;margin-bottom: 20rpx;justify-content: space-between;flex: 3;font-size: 24rpx;border-bottom: 1rpx solid #303439;">
					<view class="" style="display: flex;align-items: center;color: #9ba6b3;" >
							账号
						<!-- <view class="">
							<view style="margin-left: 20rpx;font-size: 24rpx;" class="color-b">{{item.name}}</view>
							<view style="margin-left: 20rpx;font-size: 22rpx;color: #9ba6b3;" class="">投注金额: {{item.money}}</view>
						</view> -->
					</view>
					<view class="color-b" style="font-size: 24rpx;">
						
					</view>
					<view class="" style="color: #fff;display: flex;align-items: center;">
						<span>{{userinfo.name}}</span>
							<image @click="copy(userinfo.name)" src="../../static/img/copy.png" mode="" style="width:40rpx;height: 40rpx;margin-left: 10rpx;"></image>
				
					</view>
				</view>
				<view
					style="display: flex;align-items: center;padding: 30rpx 20rpx;margin-bottom: 20rpx;justify-content: space-between;flex: 3;font-size: 24rpx;border-bottom: 1rpx solid #303439;">
					<view class="" style="display: flex;align-items: center;color: #9ba6b3;" >
							用户ID
						<!-- <view class="">
							<view style="margin-left: 20rpx;font-size: 24rpx;" class="color-b">{{item.name}}</view>
							<view style="margin-left: 20rpx;font-size: 22rpx;color: #9ba6b3;" class="">投注金额: {{item.money}}</view>
						</view> -->
					</view>
					<view class="color-b" style="font-size: 24rpx;">
						
					</view>
					<view class="" style="color: #fff;display: flex;align-items: center;">
						<span>{{userinfo.id}}</span>
						<image @click="copy(userinfo.id)" src="../../static/img/copy.png" mode="" style="width: 40rpx;height: 40rpx;margin-left: 10rpx;"></image>
				
					</view>
				</view>
				<view
					style="display: flex;align-items: center;padding: 30rpx 20rpx;margin-bottom: 20rpx;justify-content: space-between;flex: 3;font-size: 24rpx;border-bottom: 1rpx solid #303439;">
					<view class="" style="display: flex;align-items: center;color: #9ba6b3;" >
							注册日期
						<!-- <view class="">
							<view style="margin-left: 20rpx;font-size: 24rpx;" class="color-b">{{item.name}}</view>
							<view style="margin-left: 20rpx;font-size: 22rpx;color: #9ba6b3;" class="">投注金额: {{item.money}}</view>
						</view> -->
					</view>
					<view class="color-b" style="font-size: 24rpx;">
						
					</view>
					<view class="" style="color: #fff;display: flex;align-items: center;">
						<span>{{userinfo.created_at}}</span>
						
				
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		login,
		set_bank,
		getuserinfo,
		touzhujilu
	} from '../../api/api.js'
	export default {
		data() {
			return {
				gamelist:[
					{
						name:'真人',
						img:'../../static/img/zhenren.png',
						total:'0',
						money:'0',
					},
					{
						name:'电子',
						img:'../../static/img/dianzhi.png',
						total:'0',
						money:'0',
					},
					{
						name:'彩票',
						img:'../../static/img/caipiao.png',
						total:'0',
						money:'0',
					},
					{
						name:'体育',
						img:'../../static/img/tiyu.png',
						total:'0',
						money:'0',
					},
					{
						name:'电竞',
						img:'../../static/img/dianjing.png',
						total:'0',
						money:'0',
					},
					{
						name:'捕鱼',
						img:'../../static/img/buyu.png',
						total:'0',
						money:'0',
					},
					{
						name:'棋牌',
						img:'../../static/img/qipai.png',
						total:'0',
						money:'0',
					}
				],
				dayname:'今天',
				day:0,
				days:[
					{
						name:'今天'
					},
					{
						name:'昨天'
					},
					{
						name:'近七天'
					},
					{
						name:'近30天'
					}
				],
				isday:false,
				name: 'Tron',
				usdt_address:'',
				beizhu:'',
				psd: '',
				showmima: true,
				psdtype: 'password',
				forgotpsd: false,
				issubmit:false,
				datas:{},
				start_date:'',
				end_date:'',
				zongtouzhu:0,
				touzhue:0,
				shuying:0,
				userinfo:{}
			}
		},
		onLoad() {
			const today = new Date();
			
			// 获取今天的 0 点时间  
			const startOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);  
			
			// 获取今天的 24 点时间（即明天的 0 点）  
			const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1, 0, 0, 0); 
			// 格式化时间为字符串
			 this.start_date=startOfDay.toISOString().slice(0, 19).replace('T', ' ');
			 this.end_date=endOfDay.toISOString().slice(0, 19).replace('T', ' ');
			 
			// this.initdata()
			
			getuserinfo().then(res=>{
				console.log(res,'res----')
				this.userinfo=res.data.data.member
			})
		},
		methods: {
			copy(value) {
			 	uni.setClipboardData({
			 	    data: value,
			    	success: function () {
						//调用方法成功
						uni.showToast({
							title:'复制成功',
							icon:'success',
							duration: 2000
						});
					}
			 	})
			},
			navigate(item,key){
				uni.navigateTo({
					url:'/pages/betRecordDetail/betRecordDetail?type='+key
				})
			},
			 formatTimestamp(timestamp) {  
			    const date = new Date(timestamp);  
			    
			    const year = date.getFullYear();  
			    const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始  
			    const day = String(date.getDate()).padStart(2, '0');  
			    const hours = String(date.getHours()).padStart(2, '0');  
			    const minutes = String(date.getMinutes()).padStart(2, '0');  
			    const seconds = String(date.getSeconds()).padStart(2, '0');  
			    
			    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;  
			},  
			changeday(d,d2){
				this.day=d2
				this.dayname=d.name
				
					let toData = new Date(new Date().toLocaleDateString()).getTime()
					
					//今天
					let todayStart = toData //开始时间
				    let todayEnd = todayStart + 24 * 60 * 60 * 1000 - 1 //结束时间
					//昨天
					let yesterdayStart = toData - 3600 * 24 * 1000 
					let yesterdayEnd = (yesterdayStart) + 24 * 60 * 60 * 1000 - 1
					//最近7天
					let past7daysStart = toData - 7 * 3600 * 24 * 1000
					let past7daysEnd = (past7daysStart) + 24 * 60 * 60 * 1000 - 1
					//最近30天
					let past30daysStart = toData - 30 * 3600 * 24 * 1000
					let past30daysEnd = (past30daysStart) + 24 * 60 * 60 * 1000 - 1
						
						
						
						

					// console.log(this.formatTimestamp(todayStart),this.formatTimestamp(todayEnd))
					// console.log(this.formatTimestamp(yesterdayStart),this.formatTimestamp(yesterdayEnd))
					// console.log(this.formatTimestamp(past7daysStart),this.formatTimestamp(past7daysEnd))
					// console.log(this.formatTimestamp(past30daysStart),this.formatTimestamp(past30daysEnd))
				if (d.name == '今天') {  
				    console.log('今天');  
				
				    this.start_date = this.formatTimestamp(todayStart);  
				    this.end_date = this.formatTimestamp(todayEnd);  
				} else if (d.name == '昨天') {  
				    console.log('昨天');  
				 
				    this.start_date =this.formatTimestamp(yesterdayStart);  
				    this.end_date = this.formatTimestamp(yesterdayEnd);  
				} else if (d.name == '近七天') {  
				    console.log('近七天');  
				
				    this.start_date = this.formatTimestamp(past7daysStart);  
				    this.end_date = this.formatTimestamp(todayEnd);  
				} else if (d.name == '近30天') {  
				    console.log('近30天');  
				
				    this.start_date = this.formatTimestamp(past30daysStart); // 应用赋值运算符  
				    this.end_date =this.formatTimestamp(todayEnd);  
				}		// this.isday=!this.isday
				this.page=1;
				this.initdata()
			},
			initdata(){
				let token=uni.getStorageSync('token')
				touzhujilu({start_date:this.start_date,end_date:this.end_date}).then(res=>{
					console.log(res,'res')
					if(res.statusCode==200){
						this.datas=res.data.data
							this.gamelist[0]['total']=res.data.data[1].dan
							this.gamelist[0]['money']=res.data.data[1].toushujine
							this.gamelist[1]['total']=res.data.data[2].dan
							this.gamelist[1]['money']=res.data.data[2].toushujine
							this.gamelist[2]['total']=res.data.data[3].dan
							this.gamelist[2]['money']=res.data.data[3].toushujine
							this.gamelist[3]['total']=res.data.data[4].dan
							this.gamelist[3]['money']=res.data.data[4].toushujine
							this.gamelist[4]['total']=res.data.data[5].dan
							this.gamelist[4]['money']=res.data.data[5].toushujine
							this.gamelist[5]['total']=res.data.data[6].dan
							this.gamelist[5]['money']=res.data.data[6].toushujine
							this.gamelist[6]['total']=res.data.data[7].dan
							this.gamelist[6]['money']=res.data.data[7].toushujine
							
							this.zongtouzhu=res.data.data.zongtouzhu
							this.touzhue=res.data.data.touzhue
							this.shuying=res.data.data.shuying
							
							
							
							// console.log(res.data.data[1],'res.data.data[1]')
						
						// for (let e in res.data.data) {
						// console.log(e,'eee')
						// console.log(res.data.data[e],'eeee')
						// this.gamelist[e-1]['total']=res.data.data[e].dan
						// this.gamelist[e-1]['money']=res.data.data[e].toushujine
						// }
						// this.datas=[...this.datas,...res.data]
						// this.issubmit=res.data.data.member.usdt_address!=''?true:false
						// this.usdt_address=res.data.data.member.usdt_address
					}
					
				})
			},
			changemimashowhide() {
				if (this.showmima) {
					this.showmima = false
					this.psdtype = 'text'
				} else {
					this.showmima = true
					this.psdtype = 'password'
				}
			},
			goregister() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
			checkboxChange(e) {
				this.forgotpsd = !this.forgotpsd
			},
			goback(){
				uni.navigateBack({
					delta:1
				})
				// uni.reLaunch({
				// 	url:'/pages/index/index'
				// })
			},
			logins() {
				let that = this;
				// if (this.name == '') {
				// 	uni.showToast({
				// 		title: '请输入用户名',
				// 		icon: 'error',
				// 		duration: 2000
				// 	});
				// 	return false
				// }
				if (this.usdt_address == '') {
					uni.showToast({
						title: '请输入地址',
						icon: 'error',
						duration: 2000
					});
					return false
				}
				let datas = {
					username4: this.name?this.name:'',
					type: 4,
					// beizhu:this.beizhu,
					usdt_address:this.usdt_address
				}
				console.log(datas,'datas');
				// return
				set_bank(datas).then(res => {
					if (res.data.status.errorCode == 0) {
						uni.showToast({
							title: res.data.status.msg,
							icon: 'success',
							duration: 2000
						});
						console.log(that.forgotpsd)
						
					} else {
						uni.showToast({
							title: res.data.status.msg,
							icon: 'error',
							duration: 2000
						});
					}
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style scoped>
	* {
		box-sizing: border-box;
	}
	.mt-20{
		margin-top: 20rpx;
	}
	.arrow-left {
		width: 0;
		height: 0;
		border-top: 20px solid transparent;
		/* 控制箭头尖的高度 */
		border-bottom: 20px solid transparent;
		/* 控制箭头尖的高度 */
		border-right: 30px solid black;
		/* 箭头颜色 */
	}

	.login {
		width: 100%;
		min-height: 100vh;
		background-color: #202125;
	}

	.login-head {
		width: 100%;
		/* height: 514rpx; */
		/* background: url('../../static/img/loginbg.jpg') no-repeat center 50rpx; */
		/* background-size: cover; */
	}

	.head-box {
		width: 100%;
		/* padding: 32rpx 40rpx 0 40rpx; */
		display: flex;
		justify-content: center;
		align-items: center;
		/* flex-direction: column; */

	}

	.logo {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.logo .logoimg {
		width: 148rpx;
		height: 80rpx;
	}

	.logo .close {
		width: 38rpx;
		height: 38rpx;
	}

	.notes {
		text-align: center;
		align-self: flex-end;
		margin-top: 108rpx;
		color: #fff;
	}

	h4 {
		font-weight: 700;
		font-size: 34rpx;
		line-height: 40rpx;
	}

	b {
		color: #27d477;
	}

	.color-b {
		color: #fff;
	}

	.font-28 {
		font-size: 28rpx;
		margin-bottom: 20rpx;
	}

	.sub {
		line-height: 30rpx;
		color: #9ba6b3;
		font-size: 24rpx;
	}

	.title {
		text-align: center;
		/* font-weight: 600; */
		font-size: 30rpx;
		/* margin-top: 52rpx; */
		padding: 20rpx 0;
		color: #fff;
	}

	.main {
		/* margin-top: -60rpx; */
		position: relative;
	}

	.con {
		width: 100%;
		/* padding: 20rpx; */
		/* padding: 48rpx 40rpx 60rpx 40rpx; */
		/* margin-top: 86rpx; */
	}

	.common {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-direction: column;
		flex-wrap: nowrap;
		position: relative;
		margin-bottom: 20rpx;
	}

	.input {
		height: 100rpx;
		width: 100%;
		border: 0;
		padding: 24rpx 40rpx;
		border-radius: 4rpx;
		background: #1a1c20;
		overflow: visible;
		font-size: 28rpx;
		color: #fff;
	}

	.place {
		font-size: 24rpx;
		color: #7c7c7c;
	}

	.mimashowhide {
		width: 34rpx;
		height: 34rpx;
		padding: 0 16rpx;
		position: absolute;
		top: 50%;
		right: 16rpx;
		margin-top: -17rpx;
		box-sizing: content-box;
	}

	.remember-forget {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 24rpx;
		color: #fff;
	}

	/deep/ .uni-label-pointer {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	/deep/ .uni-checkbox-input {
		width: 26rpx;
		height: 26rpx;
		margin-right: 0;
		box-sizing: border-box;
		background-color: transparent;
		border-color: #33d47e;
		margin-top: -6rpx;
	}

	/deep/ .uni-checkbox-input svg {
		transform: translate(-50%, -48%) scale(0.5);
	}

	.remember-forget text {
		margin-left: 10rpx;
	}

	.login-btn {
		width: 100%;
		height: 64rpx;
		margin-top: 40rpx;
		margin-bottom: 20rpx;
		font-size: 26rpx;
		text-align: center;
		line-height: 64rpx;
		border-radius: 12rpx;
		background: #fee619;
		font-weight: 700;
		color: #1c1e22;
		box-shadow: 0 8rpx 0 0 #d9a715, inset 0 0 24rpx 6rpx rgba(243, 48, 48, .34), 0 4rpx 12rpx 6rpx rgba(255, 123, 1, .34);
	}

	.to-regist {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.left {
		color: #97a6b4;
		font-size: 28rpx;
		font-weight: 600;
	}

	.left text {
		color: #33d47e;
		font-size: 32rpx;
	}

	.to-regist image {
		width: 34rpx;
		height: 32rpx;
	}
</style>